import React from 'react'
import {connect} from 'dva'
import ProductList from '../components/Producrs'

// const Products = (props) => (
//     <h2>List of Products</h2>
// )
const Products = ({dispatch,products}) => {
    function handleDelete(id){
        console.log({id})
        dispatch({
            type: 'products/delete',
            payload: id
        })
    }
    return (
        <div>
            <h2>List</h2>
            <ProductList 
            onDelete={handleDelete} 
            products={products} />
        </div>
    )
}
export default connect(({products}) => ({
    products
}))(Products)